package com.xmb.wechat.view.qq;

import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

import com.blankj.utilcode.util.ToastUtils;
import com.xmb.wechat.R;
import com.xmb.wechat.R2;
import com.xmb.wechat.base.BaseActivity;
import com.xmb.wechat.definterface.HintListener;
import com.xmb.wechat.util.PicChooseUtils;
import com.xmb.wechat.util.PicLoadUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @Author lijiangop
 * @CreateTime 2020/5/21 09:33
 */
public class QQAccountActivity extends BaseActivity {

    private static final int REQUEST_CODE_ADD_SCREENSHOT = 007;

    @BindView(R2.id.iv_cover)
    ImageView mIvCover;
    @BindView(R2.id.et_balance)
    EditText  mEtBalance;
    @BindView(R2.id.et_q_bi)
    EditText  mEtQBi;

    private String mScreenShot;

    public QQAccountActivity() {
        super(R.layout.activity_qq_account);
    }

    @Override
    protected void initView() {
        showExemption(new HintListener() {
            @Override
            public void onConfirm() {
                //do nothing
            }

            @Override
            public void onCancel() {
                QQAccountActivity.this.finish();
            }
        });
    }

    @OnClick({R2.id.ll_bg, R2.id.btn_preview})
    public void onViewClicked(View view) {
        int id = view.getId();
        if (id == R.id.ll_bg) {
            PicChooseUtils.chooseOnePicWithCut(this, Pic -> showResult(Pic[0]));
        } else if (id == R.id.btn_preview) {
            if (TextUtils.isEmpty(mScreenShot)) {
                ToastUtils.showShort("请选择QQ账户截屏");
                return;
            }
            String balance = mEtBalance.getText().toString().trim();
            if (TextUtils.isEmpty(balance)) {
                ToastUtils.showShort("请填写余额");
                return;
            }
            String q_bi = mEtQBi.getText().toString().trim();
            if (TextUtils.isEmpty(q_bi)) {
                ToastUtils.showShort("请填写Q币");
                return;
            }
            QQAccountDetailActivity.start(this, mScreenShot, balance, q_bi);
        }
    }

    private void showResult(String picPath) {
        if (TextUtils.isEmpty(picPath))
            return;
        mScreenShot = picPath;
        PicLoadUtils.loadSdcardPic(picPath, mIvCover);
    }
}
